package strategy

import (
	"GoMaestro/internal/jencli/pub_cli"
)

// DefaultStrategy 默认发布策略，该项目的默认发布策略，对应jenkins的流水线为bak目录下的jenkinsFile
type DefaultStrategy struct {
	jobName string
	ParamStrategy
}

func NewDefaultStrategy(jobName string, paramStrategy ParamStrategy) *DefaultStrategy {
	return &DefaultStrategy{jobName: jobName, ParamStrategy: paramStrategy}
}

func (d *DefaultStrategy) Publish() (int, ParamStrategy, error) {
	taskID, _, err := pub_cli.CreateBuildTask(d.jobName, d.ToMap())
	return int(taskID), d, err
}

func (*DefaultStrategy) Stop(PipID int) (interface{}, error) {
	return nil, nil
}

func (d *DefaultStrategy) Deploy() (int, error) {
	taskID, _, err := pub_cli.CreateBuildTask(d.jobName, d.ToMapByCD())
	return int(taskID), err
}
